<?php
//-------------------------------------------------------------------//
//   Display Envents
//-------------------------------------------------------------------//
// XVI - 05/04/10
//-------------------------------------------------------------------//
if (strpos($_SERVER['PHP_SELF'],basename(__FILE__)) !== false) {
  print "Direct module access forbidden.".basename(__FILE__);
  exit;
}

	global $dbi;
	
	// Retrieve Issueid 
	$iid = $_GET['issueid'];
	if(empty($iid))	
		access_denied();
		
	// Init Issue Object
	$o_issue = new Issue($iid);
	$t_events = $o_issue->GetAllEvents();
	if(is_array($t_events))
	{
		foreach($t_events as $key => $s_events)
		{
			// Check if a file is attach to the events
			$sql = "SELECT z_files FROM z_files "; 
			$sql .= "WHERE typeid = 'issue' ";
			$sql .= "AND assignid = '$o_issue->issueid' ";
			
			
		
		
		}
	}

$num_events = count($events);
for ($x = 0;$x < $num_events;$x++) {
  if (!empty($events[$x]['fid'])) {
	$events[$x]['links'][] = array(
	  'img' => $_ENV['imgs']['file'],
	  'alt' => 'Download File',
	  'url' => '?module=download&fid='.$events[$x]['fid']
	);
  }
  
  if ($events[$x]['userid'] == $_SESSION['userid']
  or issue_priv($_GET['issueid'],"edit_events")) {
	if (!$disable_edit 
	or ($disable_edit and is_admin($_SESSION['userid']))) {
	  $events[$x]['links'][] = array(
		'img' => $_ENV['imgs']['edit'],
		'alt' => $lg->edit,
		'url' => '?module=issues&action=edit&issueid='.$_GET['issueid'].'&gid='.$issue['gid'].'&eid='.$events[$x]['eid']
	  );
	}
  }

  if (is_employee() and issue_priv($_GET['issueid'],"view_private")) {
	$url = "?module=issues&action=view&issueid=".$_GET['issueid']."&eid=".$events[$x]['eid'];

	$events[$x]['links'][] = array(
	  'img' => $events[$x]['private'] == "t" ? $_ENV['imgs']['private'] : $_ENV['imgs']['public'],
	  'alt' => $events[$x]['private'] == "t" ? $lg->make_public : $lg->make_private,
	  'url' => $events[$x]['private'] == "t" ? $url."&type=public" : $url."&type=private"
	);
  }
  $events[$x]['class'] = $events[$x]['private'] == "t" ? "private" : "data";
}

?>